 <%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %><%--
  Created by IntelliJ IDEA.
  User: XY004
  Date: 2024/9/23
  Time: 9:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>整表查询数据</title>
    <%
        ResultSet rs;
    %>
    <%
        String dbName = "jdbc";
        String userName = "root";
        String userPasswd = "123456";
        String url = "mysql://127.0.0.1/"+dbName +"?user="+userName+"&password="+userPasswd;
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn = DriverManager.getConnection(url);
        Statement statement = conn.createStatement();
        String sql = "select * from student";
        rs = statement.executeQuery(sql);
    %>
</head>
<body>
<form action="first.jsp" method="post">
    <table>
        <th colspan="2">查询条件</th>
        <tr>
            <td>学号:</td>
            <td>
                <input type="text" name="stuid" id="stuid">
            </td>
        </tr>
        <tr aria-rowspan="2">
            <td><input type="submit" value="提交"></td>
        </tr>
    </table>
</form>
<table border="1">
    <th colspan="4" style="font-size: x-large;alignment: center;">学生信息表</th>
    <tr style="text-align: center">
        <th>学号</th>
        <th>姓名</th>
        <th>出生日期</th>
        <th>所在班级</th>
    </tr>
    <TR>
            <%while (rs.next()){ %>
    <tr style="text-align: center;">
        <td><%=rs.getString(1)%></td>
        <td><%=rs.getString(2)%></td>
        <td><%=rs.getString(3)%></td>
        <td><%=rs.getString(4)%></td>
    </tr>
    <% } %>
    <%
        rs.close();
        statement.close();
        conn.close();
    %>
    </TR>
</table>
</body>
</html>